﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace CXJ.Libiary
{
    [System.AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
    public class DBColumnAttribue : Attribute
    {
        public bool IsDBColumn { get; set; }

        //Insert 语句 插入列
        public bool IsInsert { get; set; }

        //Update 语句 Set 更新列 Update Where条件默认字段为主键
        public bool IsUpdate { get; set; }

        //Delete 语句where条件列
        public bool IsDelete { get; set; }

        //Select 语句中的查询列
        public bool IsSelect { get; set; }

        //字段数据类型
        public DbType DBType { get; set; }

        public DBColumnAttribue()
        {
            IsDBColumn = false;
            IsInsert = false;
            IsUpdate = false;
            IsDelete = false;
            IsSelect = false;
            DBType = DbType.AnsiString;
        }
        public DBColumnAttribue(bool _isDBColumn)
        {
            IsDBColumn = _isDBColumn;
            IsInsert = true;
            IsUpdate = true;
            IsDelete = false;
            IsSelect = true;
            DBType = DbType.AnsiString;
        }
        /// <summary>
        /// 默认顺序 - 增 删 改 查
        /// </summary>
        /// <param name="_isDBColumn">表示为数据列</param>
        /// <param name="_IsInsert">Insert 语句 插入列</param>
        /// <param name="_IsDelete">Delete 语句where条件列</param>
        /// <param name="_IsUpdate">Update 语句 Set 更新列 Update Where条件默认字段为主键</param>
        /// <param name="_IsSelect">Select 语句中的查询列</param>
        public DBColumnAttribue(bool _isDBColumn, bool _IsInsert, bool _IsDelete, bool _IsUpdate, bool _IsSelect)
        {
            IsDBColumn = _isDBColumn;
            IsInsert = _IsInsert;
            IsUpdate = _IsUpdate;
            IsDelete = _IsDelete;
            IsSelect = _IsSelect;
        }

        /// <summary>
        /// 默认顺序 - 增 删 改 查
        /// </summary>
        /// <param name="_isDBColumn">表示为数据列</param>
        /// <param name="_IsInsert">Insert 语句 插入列</param>
        /// <param name="_IsDelete">Delete 语句where条件列</param>
        /// <param name="_IsUpdate">Update 语句 Set 更新列 Update Where条件默认字段为主键</param>
        /// <param name="_IsSelect">Select 语句中的查询列</param>
        public DBColumnAttribue(bool _isDBColumn, bool _IsInsert, bool _IsDelete, bool _IsUpdate, bool _IsSelect, DbType _DBType)
        {
            IsDBColumn = _isDBColumn;
            IsInsert = _IsInsert;
            IsUpdate = _IsUpdate;
            IsDelete = _IsDelete;
            IsSelect = _IsSelect;
            DBType = _DBType;
        }
    }
}
